<?php
include("database.php");
session_start();

	$idcheck = base64_decode($_POST['donate_id']);
	$GeneratedTimestamp=date('Y-m-d H:i:s');
	
	if($_POST==null) {}
	else {
    	extract($_POST);  
		if(!isset($_SESSION["id".$idcheck])) {
				$_SESSION["id".$idcheck] = true;
				$update = mysqli_query($con,"UPDATE DonateList SET Flags = Flags+1 WHERE ID='$idcheck'") or die (mysql_error());		
				$query="INSERT into FlagReason (donate_id, name, contact, reason, time)
				VALUES ('$idcheck', '$name', '$contact', '$reason', '$GeneratedTimestamp')";        
				if (!mysqli_query($con,$query)) { die('Error: ' . mysqli_error($con)); }
				echo 'success';
		}
		else echo 'failed';
    }

?>